package com.hsmpay.mobile.action.trans;

import com.hsmpay.common.pojo.user.User;
import com.hsmpay.common.util.DateConvertUtil;
import com.hsmpay.common.util.NumberUtil;
import com.hsmpay.mobile.action.account.qian48.Q4BaseAction;
import com.hsmpay.mobile.pojo.finance.BatchClearLog;
import com.hsmpay.mobile.pojo.trans.TransOrder;
import com.hsmpay.mobile.pojo.trans.TransPriorSettle;
import com.hsmpay.mobile.service.finance.BatchClearLogService;
import com.hsmpay.mobile.service.trans.TransPriorSettleService;
import com.hsmpay.utils.Des3;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 交易 action
 *
 * @author 颜铃璋
 * @date 2013-1-28
 */
@Controller("transAction")
@Scope("prototype")
public class TransAction extends TransBaseAction {
    private static final long serialVersionUID = 5704914302763211010L;
    private static Logger log = Logger.getLogger(TransAction.class);

    private String orderNum;//交易订单
    private Integer clientType;//客户端类型：1网站 2安卓 3iphone 4ipad
    private Integer terminalTypeId;//终端类型（1花生米 2）
    //--- 交易查询 参数 ---
    private Date startDate;//起始时间
    private Date endDate;//结束时间
    private TransPriorSettle transPriorSettle;


    @Resource(name = "transPriorSettleService")
    private TransPriorSettleService<TransPriorSettle, Long> transPriorSettleService;
    @Resource(name="batchClearLogService")
    private BatchClearLogService<BatchClearLog,Long> batchClearLogService;//结算日志

    /**
     * 获得用户交易列表
     *
     * @return
     * @throws Exception
     */
    public String transactionList() throws Exception {
        log.debug("--- transactionList() start ---");
        JSONObject js = JSONObject.fromObject(getRequest().getAttribute(FC_DATA));
        if (js.containsKey("userId"))
            userId = Long.parseLong(js.getString("userId"));
        if (js.containsKey("startDate")) {
            String startDateStr = js.getString("startDate");
            startDate = DateConvertUtil.stringDate(startDateStr);
        }
        if (js.containsKey("endDate")) {
            String endDateStr = js.getString("endDate");
            endDate = DateConvertUtil.stringDate(endDateStr);
        }
        if (js.containsKey("start"))
            start = Integer.parseInt(js.getString("start"));
        if (js.containsKey("stop"))
            stop = Integer.parseInt(js.getString("stop"));

        log.debug("userId = " + userId);
        log.debug("startDate = " + startDate);
        log.debug("endDate = " + endDate);
        log.debug("start = " + start);
        log.debug("stop = " + stop);
        if (null == userId) {
            log.warn("获得用户交易列表时, 传入参数userId为空");
            sendAppErrorMsg("6001", "userId");
            return null;
        }
        if (null == startDate || null == endDate || endDate.before(startDate)) {
            log.warn("获得用户交易列表时, 日期选择错误!");
            sendAppErrorMsg("6051");
            return null;
        }
        if (null == start) {
            start = 1;
        }
        if (null == stop) {
            stop = 20;
        }
        try {
            Map<String, Object> result = new LinkedHashMap<String, Object>();

            endDate = DateConvertUtil.getSpecifiedDayAfter(endDate);
            TransOrder param = new TransOrder();
            param.setUserId(userId);
            param.setStart(start);
            param.setStop(stop);
            param.setStartDate(startDate);
            param.setEndDate(endDate);
            param.setOtherParam(" O.ORDERTYPEID <> 0 ");//结算信息  不给用户看

            DecimalFormat df = new DecimalFormat("######0.00");
            List<TransOrder> transOrderList = transOrderService.searchEntityList(param);
            List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
            Map<String, Object> element = null;
            //Date date = new Date();
            int status = 0;
            for (TransOrder transOrder : transOrderList) {
                element = new HashMap<String, Object>();
                element.put("orderNum", transOrder.getOrderNum());
                element.put("category", transOrder.getCategory());
                element.put("transTime", transOrder.getCreateDate().getTime());
                element.put("orderTypeId", transOrder.getOrderTypeId());
                //element.put("transTime", DateConvertUtil.orderTimeFormat(date,transOrder.getUpdateLongTime()));

                status = transOrder.getStatus();
                if (2 == status || 1 == status) {
                    status = 1;
                } else if (5 == status || 9 == status) {
                } else {
                    status = 0;
                }
                element.put("status", status);

                element.put("transMoney", df.format(transOrder.getTransMoney()));


                //如果是收款  并且已提现  那么查出提现状态
                if (null != transOrder.getCashOrderNum()) {
                    param = new TransOrder();
                    param.setOrderNum(transOrder.getCashOrderNum());
                    param = transOrderService.searchEntity(param);

                    if (null != param) {
                        element.put("cashStatus", param.getStatus());//提现状态
                    } else {
                        element.put("cashStatus", 2);//提现状态
                    }
                }

                resultList.add(element);
            }

            result.put("reqCode", "0000");
            result.put("reqMsg", "获得用户交易列表成功！");
            result.put("transList", resultList);
            sendAppMsg(result);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        } finally {
            log.debug("--- transactionList() end ---");
        }
        return null;
    }

    /**
     * 获得微信用户交易列表
     *
     * @return
     * @throws Exception
     */
    public String weChartTransactionList() throws Exception {
        log.debug("--- weChartTransactionList() start ---");
        String pageNo = getRequest().getParameter("pageNo");
        String TotalPage = getRequest().getParameter("TotalPage");
        User user = (User) getSession().getAttribute("SESSION_USER");

        if (null == user) {
            log.warn("用户会话失效，请重新登录！");
            sendAppErrorMsg("9990");
            return null;
        }

        if(Long.valueOf(TotalPage) > 1 && Long.valueOf(pageNo) > Long.valueOf(TotalPage)){
            return null;
        }

        start = (Integer.valueOf(pageNo)-1) * 20 + 1;
        stop = (Integer.valueOf(pageNo)-1) * 20 + 20;

        try {
            JSONObject result = new JSONObject();
            TransOrder param = new TransOrder();
            param.setUserId(user.getUserId());
            param.setOtherParam(" O.ORDERTYPEID <> 0 ");//结算信息  不给用户看
            int totalTransOrder = transOrderService.getEntityCount(param);
            int totalPage = (totalTransOrder / 20) + 1;
            param.setStart(start);
            param.setStop(stop);
            List<TransOrder> transOrderList = transOrderService.searchEntityList(param);

            DecimalFormat df = new DecimalFormat("######0.00");
            JSONArray resultArray = new JSONArray();
            JSONObject element = null;
            for (TransOrder transOrder : transOrderList) {
                element = new JSONObject();
                element.put("orderNum", transOrder.getOrderNum());
                element.put("category", transOrder.getCategory());
                element.put("transTime", transOrder.getCreateDate());
                element.put("TRANS_TYPE", "3");
                element.put("TRANS_STATE", transOrder.getStatus());
                element.put("transMoney", df.format(transOrder.getTransMoney()));
                if(1 == transOrder.getOrderTypeId().intValue()){
                    element.put("remark", "消费");
                }else if(8 == transOrder.getOrderTypeId().intValue()){
                    element.put("remark", "提现");
                }else if(17 == transOrder.getOrderTypeId().intValue() || 16 == transOrder.getOrderTypeId().intValue()){
                    element.put("remark", "提现");
                }

                //如果是收款  并且已提现  那么查出提现状态
                if (null != transOrder.getCashOrderNum()) {
                    param = new TransOrder();
                    param.setOrderNum(transOrder.getCashOrderNum());
                    param = transOrderService.searchEntity(param);

                    if (null != param) {
                        element.put("cashStatus", param.getStatus());//提现状态
                    } else {
                        element.put("cashStatus", 2);//提现状态
                    }
                }

                resultArray.add(element);
            }
            result.put("totalPage",totalPage);
            result.put("totleResult",transOrderList.size());
            result.put("code", "0000");
            result.put("msg", "获得用户交易列表成功！");
            result.put("transList", resultArray);
            if(0 == transOrderList.size()){
                result.put("msg", "暂无交易记录!");
            }
            sendWeChatMsg(result.toString());
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        } finally {
            log.debug("--- transactionList() end ---");
        }
        return null;
    }

    /**
     * 获得微信用户结算列表
     *
     * @return
     * @throws Exception
     */
    public String weChartSettleList() throws Exception {
        log.debug("--- weChartSettleList() start ---");
        User user = (User) getSession().getAttribute("SESSION_USER");

        if (null == user) {
            log.warn("用户会话失效，请重新登录！");
            sendAppErrorMsg("9990");
            return null;
        }
        try {
            JSONObject result = new JSONObject();
            BatchClearLog bcl = new BatchClearLog();
            bcl.setLoginName(user.getLoginName());
            bcl.setBankCard(user.getBankCard());
            bcl.setTerminalTypeId(user.getTerminalTypeId());
            bcl.setBranchesBankCode(user.getBranchesBankCode());
            List<BatchClearLog> batchClearLogList = batchClearLogService.searchEntityList(bcl);

            DecimalFormat df = new DecimalFormat("######0.00");
            JSONArray resultArray = new JSONArray();
            JSONObject element = null;
            for (BatchClearLog batchClearLog : batchClearLogList) {
                element = new JSONObject();
                element.put("orderNum", batchClearLog.getId());
                element.put("category", "结算");
                element.put("settleDate", batchClearLog.getCreateDate());

                int status = batchClearLog.getStatus();
                String TRANS_STATE = "";
                if (1 == status) {
                    TRANS_STATE = "SUCCESS";
                }else if(2 == status){
                    TRANS_STATE = "UNDERWAY";
                }else if(3 == status){
                    TRANS_STATE = "WAIT";
                }else{
                    TRANS_STATE = "FAIL";
                }
                element.put("status", TRANS_STATE);

                element.put("settleAmount", df.format(batchClearLog.getTransMoney()));

                resultArray.add(element);
            }
            result.put("code", "0000");
            result.put("msg", "获得用户交易列表成功！");
            result.put("settleBillList", resultArray);
            if(0 == batchClearLogList.size()){
                result.put("msg", "暂无结算记录！");
            }
            sendWeChatMsg(result.toString());
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        } finally {
            log.debug("--- transactionList() end ---");
        }
        return null;
    }

    /**
     * 获得用户交易详情
     *
     * @return
     * @throws Exception
     */
    public String transactionDetail() throws Exception {
        log.debug("--- transactionDetail() start ---");
        JSONObject js = JSONObject.fromObject(getRequest().getAttribute(FC_DATA));

        clientType = Integer.parseInt(js.getString("clientType"));
        terminalTypeId = Integer.parseInt(js.getString("terminalTypeId"));
        if (js.containsKey("orderNum"))
            orderNum = js.getString("orderNum");

        log.debug("orderNum = " + orderNum);
        log.debug("clientType = " + clientType);//
        log.debug("terminalTypeId = " + terminalTypeId);//

        if (StringUtils.isBlank(orderNum)) {
            log.warn("修改密码时, 传入参数orderNum为空");
            sendAppErrorMsg("6001", "orderNum");
            return null;
        }
        try {
            //DecimalFormat df=new DecimalFormat("######0.00");
            TransOrder transOrder = new TransOrder();
            transOrder.setOrderNum(orderNum);
            transOrder = transOrderService.searchEntity(transOrder);
            if (null == transOrder) {
                String message = encryptAppMsg(0, "9999", "不存在该订单,你调错接口了！");
                sendAppMsg(message);
                return null;
            }
            Map<String, Object> result = new HashMap<String, Object>();
            result.put("orderTypeId", transOrder.getOrderTypeId());
            result.put("category", transOrder.getCategory());
            result.put("transMoney", NumberUtil.round(transOrder.getTransMoney(), 2));
            result.put("transTime", transOrder.getCreateDate().getTime());

            int status = transOrder.getStatus();
            if (2 == status || 1 == status) {
                status = 1;
            } else if (5 == status || 9 == status || 8 == status) {
            } else {
                status = 0;
            }
            result.put("status", status);


            result.put("objectiveName", transOrder.getObjectiveName());
            result.put("objectiveCard", transOrder.getObjectiveCard());
            result.put("objectiveOpBank", transOrder.getObjectiveOpBank());
            result.put("name", transOrder.getName());
            result.put("bankCard", transOrder.getBankCard());

            //客户端 需要查询
            transPriorSettle = new TransPriorSettle();
            transPriorSettle.setOrderNum(transOrder.getOrderNum());
            transPriorSettle = transPriorSettleService.searchEntity(transPriorSettle);

			/*element.put("merchantName", Q4BaseAction.MERCHANT_NAME);//商户名称
			element.put("merchantId", Q4BaseAction.MERCHANT_ID);//商户编号
			element.put("terminalId", transPriorSettle.getTerminalId());//终端编号
			element.put("acquirersName", null == transPriorSettle.getAcquirersName() ? "" : transPriorSettle.getAcquirersName());//收单行
			element.put("issueBank", null == transPriorSettle.getIssueBank() ? "" : transPriorSettle.getIssueBank());//发卡行
			element.put("bankCard", transOrder.getBankCard());//收款卡号
			element.put("cardType", null == transPriorSettle.getCardType()? "" : transPriorSettle.getCardType());//收款卡号
			element.put("expireDate", null == transPriorSettle.getExpireDate() ? "" : transPriorSettle.getExpireDate());//卡有效期（预授权时）
			element.put("batchId", null == transPriorSettle.getBatchId() ? "" : transPriorSettle.getBatchId());//批次号
			element.put("authorizationCode", null == transPriorSettle.getAuthorizationCode() ? "" : transPriorSettle.getAuthorizationCode());//授权码
			element.put("bankTransTime", transPriorSettle.getBankTransTime());//日期/时间
			element.put("transMoney", transOrder.getTransMoney());//交易金额
			*/
            if (status == 1 && (transOrder.getOrderTypeId().intValue() == 1 || transOrder.getOrderTypeId().intValue() == 7)) {
                String cParam = terminalTypeId + "_" + transPriorSettle.getId();
                String cParamB64 = new String(Des3.encodeXP(cParam));
                result.put("certificateUrl", Q4BaseAction.Certificate + cParamB64);
                //result.put("certificateUrl",Q4BaseAction.Certificate+terminalTypeId+"_"+transPriorSettle.getId()+".jsp");
            }
            //element.put("reqCode", transPriorSettle.getResponseCode());
            result.put("reqMsg", "获得用户交易详情成功！");
            if (StringUtils.isNotBlank(transOrder.getTransPriorSettle().getBankMessage()))
                result.put("reqMsg", transOrder.getTransPriorSettle().getBankMessage());
            else if (null != transOrder.getTransAfterSettle() && StringUtils.isNotBlank(transOrder.getTransAfterSettle().getMessage())) {
                String message = transOrder.getTransAfterSettle().getMessage();
                String[] messageArray = message.split("：");
                result.put("reqMsg", messageArray[messageArray.length - 1]);
            }
            result.put("reqCode", "0000");
            sendAppMsg(result);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        } finally {
            log.debug("--- transactionDetail() end ---");
        }
        return null;
    }

    /**
     * 获得微信公众号用户交易详情
     *
     * @return
     * @throws Exception
     */
    public String customerTransactionDetail() throws Exception {
        log.debug("--- customerTransactionDetail() start ---");

        String orderNum = getRequest().getParameter("externalId");
        log.debug("orderNum = " + orderNum);

        if(StringUtils.isBlank(orderNum)){
            log.warn("获取交易详情时, 传入orderNum为空");
            sendAppErrorMsg("6001","orderNum");
        }
        try {
            TransOrder transOrder = new TransOrder();
            transOrder.setOrderNum(orderNum);
            transOrder = transOrderService.searchEntity(transOrder);
            if (null == transOrder) {
                sendWeChatErrorMsg("9999","不存在该订单!");
                return null;
            }
            JSONObject result = new JSONObject();
            DecimalFormat df = new DecimalFormat("######0.00");

            String merchantName = userService.getUserById(transOrder.getUserId()).getNickName();
            String status = "";
            if(0 == transOrder.getStatus()){
                status = "交易失败";
                merchantName = "";
            }else if(1 == transOrder.getStatus()) {
                status = "交易成功";
            }else if(2 == transOrder.getStatus()){
                status = "处理中";
            }else if(3 == transOrder.getStatus()){
                status = "未付";
                merchantName = "";
            }else {
                status = "交易失败";
                merchantName = "";
            }

            result.put("code", "0");
            result.put("msg", "获得用户交易详情成功!");
            result.put("status", status);
            result.put("merchantName", merchantName);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            result.put("transTime", sdf.format(transOrder.getCreateDate()).toString());
            result.put("amount", df.format(NumberUtil.round(transOrder.getTransMoney(), 2)));
            result.put("remark", transOrder.getCategory());
            if(16 == transOrder.getOrderTypeId() || 17 == transOrder.getOrderTypeId()){
                result.put("remark", "提现");
            }
            result.put("orderNum", orderNum);
            result.put("orderTypeId", transOrder.getOrderTypeId());

            if(transOrder.getOrderTypeId() == 1 && transOrder.getStatus() == 1){//成功的收款
                if (null != transOrder.getCashOrderNum()) {
                    TransOrder cashOrder = new TransOrder();
                    cashOrder.setOrderNum(transOrder.getCashOrderNum());
                    cashOrder = transOrderService.searchEntity(cashOrder);

                    if (null != cashOrder && (cashOrder.getStatus() == 1 || cashOrder.getStatus() == 2)) {
                        result.put("cashBtn", "2");//隐藏式提现按钮
                    } else {
                        result.put("cashBtn", "1");//显示提现按钮
                    }
                }else {
                    result.put("cashBtn", "1");//显示提现按钮
                }
            }else {
                result.put("cashBtn", "0");//不显示提现按钮
            }

            sendWeChatMsg(result.toString());
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        } finally {
            log.debug("--- customerTransactionDetail() end ---");
        }
        return null;
    }

    public String canCashList() throws Exception {
        log.debug("--- transactionList() start ---");
        JSONObject js = JSONObject.fromObject(getRequest().getAttribute(FC_DATA));
        if (js.containsKey("userId"))
            userId = Long.parseLong(js.getString("userId"));

        Date date = new Date();
        startDate = getInitStartDateTime(date);
        endDate = getInitEndDateTime(date);

        if (js.containsKey("start"))
            start = Integer.parseInt(js.getString("start"));
        if (js.containsKey("stop"))
            stop = Integer.parseInt(js.getString("stop"));

        log.debug("userId = " + userId);
        log.debug("startDate = " + startDate);
        log.debug("endDate = " + endDate);
        log.debug("start = " + start);
        log.debug("stop = " + stop);
        if (null == userId) {
            log.warn("获得用户交易列表时, 传入参数userId为空");
            sendAppErrorMsg("6001", "userId");
            return null;
        }
        if (null == start) {
            start = 1;
        }
        if (null == stop) {
            stop = 20;
        }
        try {
            Map<String, Object> result = new LinkedHashMap<String, Object>();

            endDate = DateConvertUtil.getSpecifiedDayAfter(endDate);
            TransOrder param = new TransOrder();
            param.setUserId(userId);
            param.setStart(start);
            param.setStop(stop);
            param.setStartDate(startDate);
            param.setEndDate(endDate);
            param.setOrderTypeId(1L);//收款
            param.setStatus(1);//交易成功
            //param.setOtherParam(" O.ORDERTYPEID = 8 OR (O.ORDERTYPEID = 1 AND O.STATUS = 1) ");

            DecimalFormat df = new DecimalFormat("######0.00");
            List<TransOrder> transOrderList = transOrderService.searchEntityList(param);
            List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
            Map<String, Object> element = null;
            //Date date = new Date();
            int status = 0;
            for (TransOrder transOrder : transOrderList) {
                element = new HashMap<String, Object>();
                element.put("orderNum", transOrder.getOrderNum());
                element.put("category", transOrder.getCategory());
                element.put("transTime", transOrder.getCreateDate().getTime());
                element.put("orderTypeId", transOrder.getOrderTypeId());
                //element.put("transTime", DateConvertUtil.orderTimeFormat(date,transOrder.getUpdateLongTime()));

                status = transOrder.getStatus();
//				if(2 == status || 1 == status){
//					status = 1;
//				}else if(5 == status || 9 == status){
//				}else{
//					status = 0;
//				}
                element.put("status", status);

                element.put("transMoney", df.format(transOrder.getTransMoney()));


                //如果是收款  并且已提现  那么查出提现状态
                if (null != transOrder.getCashOrderNum()) {
                    param = new TransOrder();
                    param.setOrderNum(transOrder.getCashOrderNum());
                    param = transOrderService.searchEntity(param);

                    if (null != param) {
                        element.put("cashStatus", param.getStatus());//提现状态
                    } else {
                        element.put("cashStatus", 2);//提现状态
                    }
                }

                resultList.add(element);
            }

            result.put("reqCode", "0000");
            result.put("reqMsg", "获得用户交易列表成功！");
            result.put("transList", resultList);
            sendAppMsg(result);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        } finally {
            log.debug("--- transactionList() end ---");
        }
        return null;
    }

    /**
     * 获取用户交易日统计
     * @return
     */
    public String getUserTransDayStatistics() throws Exception {
        JSONObject js = JSONObject.fromObject(getRequest().getAttribute(FC_DATA));
        if (js.containsKey("userId"))
            userId = Long.parseLong(js.getString("userId"));
        if(null == userId){
            log.warn("获取用户交易日统计时, 传入参数userId为空!");
            sendAppErrorMsg("6001", "userId");
            return null;
        }
        try{
            TransOrder transOrder = new TransOrder();
            transOrder.setOrderTypeId(1L);//收款
            transOrder.setUserId(userId);
            transOrder.setStatus(1);
            Calendar calendar = Calendar.getInstance();
            calendar.add(Calendar.DAY_OF_MONTH,-1);
            calendar.set(Calendar.HOUR_OF_DAY,23);
            calendar.set(Calendar.MINUTE,0);
            calendar.set(Calendar.SECOND,0);
            Date startDate = calendar.getTime();
            transOrder.setStartDate(startDate);
            transOrder.setEndDate(new Date());
            List<TransOrder> transOrderList = transOrderService.searchEntityList(transOrder);
            Double totalMoney = 0.00;
            for(TransOrder order : transOrderList){
                totalMoney += order.getTransMoney();
                totalMoney = NumberUtil.roundF2(totalMoney);
            }
            Map<String, Object> result = new LinkedHashMap<String, Object>();
            result.put("reqCode", "0000");
            result.put("reqMsg", "获取用户交易日统计成功！");
            result.put("totalMoney",String.valueOf(totalMoney));
            sendAppMsg(result);
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }
        return null;
    }

    /**
     * 获取用户交易月统计
     * @return
     */
    public String getUserTransMonthStatistics() throws Exception {
        JSONObject js = JSONObject.fromObject(getRequest().getAttribute(FC_DATA));
        if (js.containsKey("userId"))
            userId = Long.parseLong(js.getString("userId"));
        if(null == userId){
            log.warn("获取用户交易月统计时, 传入参数userId为空!");
            sendAppErrorMsg("6001", "userId");
            return null;
        }
        try{
            TransOrder transOrder = new TransOrder();
            transOrder.setOrderTypeId(1L);//收款
            transOrder.setUserId(userId);
            transOrder.setStatus(1);
            Calendar calendar = Calendar.getInstance();
            calendar.add(Calendar.MONTH,-1);
            calendar.set(Calendar.DAY_OF_MONTH,calendar.getActualMaximum(calendar.DAY_OF_MONTH));
            calendar.set(Calendar.HOUR_OF_DAY,23);
            calendar.set(Calendar.MINUTE,0);
            calendar.set(Calendar.SECOND,0);
            Date startDate = calendar.getTime();
            transOrder.setStartDate(startDate);
            transOrder.setEndDate(new Date());
            List<TransOrder> transOrderList = transOrderService.searchEntityList(transOrder);
            Double totalMoney = 0.00;
            for(TransOrder order : transOrderList){
                totalMoney += order.getTransMoney();
                totalMoney = NumberUtil.roundF2(totalMoney);
            }
            Map<String, Object> result = new LinkedHashMap<String, Object>();
            result.put("reqCode", "0000");
            result.put("reqMsg", "获取用户交易月统计成功！");
            result.put("totalMoney",String.valueOf(totalMoney));
            sendAppMsg(result);
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }
        return null;
    }

    //---------------------set get start---------------------
    public void setOrderNum(String orderNum) {
        this.orderNum = orderNum;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public void setClientType(Integer clientType) {
        this.clientType = clientType;
    }

    public void setTerminalTypeId(Integer terminalTypeId) {
        this.terminalTypeId = terminalTypeId;
    }
    //---------------------set get end-----------------------
}
